// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 

package com.nnee.p_pr.p_activity;

import android.app.*;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.net.Uri;
import android.os.*;
import android.text.TextUtils;
import android.view.*;
import android.widget.*;
import com.nnee.p_fk.cls_ActivityEx;
import com.nnee.p_g.cls_b;
import com.nnee.p_pr.p_a.cls_i;
import com.nnee.p_up.cls_ProgressInfo;
import com.nnee.p_up.cls_c;
import java.io.*;
import java.util.ArrayList;
import java.util.Iterator;

// Referenced classes of package com.nnee.p_pr.p_activity:
//            fb, da, ey, ex, 
//            fa, ez

public class cls_PRISActivityUpdate extends cls_ActivityEx
    implements android.view.View.OnClickListener
{

    public cls_PRISActivityUpdate()
    {
        j = false;
        r = null;
        s = null;
        t = null;
        u = null;
        A = new cls_fb(this);
    }

    private void a(int i1, int j1)
    {
        android.os.Message message = A.obtainMessage(2, i1, j1);
        A.sendMessage(message);
    }

    static void a(cls_PRISActivityUpdate prisactivityupdate)
    {
        prisactivityupdate.x();
    }

    static void a(cls_PRISActivityUpdate prisactivityupdate, int i1)
    {
        prisactivityupdate.j(i1);
    }

    static void a(cls_PRISActivityUpdate prisactivityupdate, int i1, int j1)
    {
        prisactivityupdate.a(i1, j1);
    }

    static void a(cls_PRISActivityUpdate prisactivityupdate, cls_ProgressInfo progressinfo)
    {
        prisactivityupdate.a(progressinfo);
    }

    private void a(cls_ProgressInfo progressinfo)
    {
        boolean flag = true;
        Notification notification = new Notification();
        notification.icon = 0x1080081;
        notification.flags = 2 | notification.flags;
        Object aobj[] = new Object[1];
        aobj[0] = t.getText(0x7f0a0000);
        notification.tickerText = getString(0x7f0a018b, aobj);
        RemoteViews remoteviews = new RemoteViews(getPackageName(), 0x7f03001d);
        remoteviews.setTextViewText(0x7f0d0018, t.getText(0x7f0a0000));
        int i1 = progressinfo.c();
        int j1 = progressinfo.b();
        Intent intent;
        if(progressinfo.c() != -1)
            flag = false;
        remoteviews.setProgressBar(0x7f0d005e, i1, j1, flag);
        remoteviews.setTextViewText(0x7f0d005b, progressinfo.d());
        remoteviews.setImageViewResource(0x7f0d005a, 0x7f0200a6);
        notification.contentView = remoteviews;
        intent = new Intent();
        intent.setClass(t, com.nnee.p_pr.p_activity.cls_PRISActivityUpdate.class);
        notification.contentIntent = PendingIntent.getBroadcast(t, 0, intent, 0);
        u.notify((int)progressinfo.e(), notification);
    }

    private void a(String s1, String s2, String s3, long l1, long l2)
    {
        k = new cls_da(this, s1, s2, s3, l1, l2);
        k.start();
    }

    static boolean a()
    {
        return c;
    }

    private boolean a(long l1)
    {
        StatFs statfs = new StatFs((new File(Environment.getExternalStorageDirectory().getPath())).getPath());
        boolean flag;
        if((long)statfs.getBlockSize() * (long)(-8 + statfs.getAvailableBlocks()) > l1)
            flag = true;
        else
            flag = false;
        return flag;
    }

    static boolean a(cls_PRISActivityUpdate prisactivityupdate, String s1, String s2)
    {
        return prisactivityupdate.b(s1, s2);
    }

    static cls_ProgressInfo b(cls_PRISActivityUpdate prisactivityupdate, cls_ProgressInfo progressinfo)
    {
        prisactivityupdate.s = progressinfo;
        return progressinfo;
    }

    static void b(cls_PRISActivityUpdate prisactivityupdate)
    {
        prisactivityupdate.v();
    }

    static void b(cls_PRISActivityUpdate prisactivityupdate, int i1)
    {
        prisactivityupdate.i(i1);
    }

    static boolean b()
    {
        return b;
    }

    private boolean b(String s1, String s2)
    {
        boolean flag = false;
        if(!TextUtils.isEmpty(s1) && s2 != null){
        	File file = new File(s1);
            FileInputStream fileinputstream = null;
			try {
				fileinputstream = new FileInputStream(file);
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
            String s3 = com.nnee.p_up.cls_c.a(com.nnee.p_up.cls_c.a(fileinputstream));
            if(b)
                com.nnee.p_g.cls_b.e(a, (new StringBuilder()).append("computed-md5==").append(s3).toString());
            if(s3.equals(s2))
                flag = true;
            try
            {
                fileinputstream.close();
            }
            catch(IOException ioexception)
            {
                com.nnee.p_g.cls_b.f(a, (new StringBuilder()).append("failed to close file input stream ocls_f file ").append(s1).toString());
                ioexception.printStackTrace();
            }
            
         
            com.nnee.p_g.cls_b.e(a, (new StringBuilder()).append("file not exist at ").append(s1).toString());
 
        }
 
        return flag;
 
    }

    static String c()
    {
        return a;
    }

    static void c(cls_PRISActivityUpdate prisactivityupdate)
    {
        prisactivityupdate.h();
    }

    static void c(cls_PRISActivityUpdate prisactivityupdate, int i1)
    {
        prisactivityupdate.l(i1);
    }

    static void d(cls_PRISActivityUpdate prisactivityupdate)
    {
        prisactivityupdate.g();
    }

    static cls_ProgressInfo e(cls_PRISActivityUpdate prisactivityupdate)
    {
        return prisactivityupdate.s;
    }

    private void e()
    {
        f();
        j = false;
        e.setEnabled(true);
    }

    static NotificationManager f(cls_PRISActivityUpdate prisactivityupdate)
    {
        return prisactivityupdate.u;
    }

    private void f()
    {
        if(k != null)
            k.interrupt();
    }

    private void g()
    {
        setContentView(v, new android.widget.LinearLayout.LayoutParams(-1, -2));
    }

    static void g(cls_PRISActivityUpdate prisactivityupdate)
    {
        prisactivityupdate.e();
    }

    static String h(cls_PRISActivityUpdate prisactivityupdate)
    {
        return prisactivityupdate.r;
    }

    private void h()
    {
        if(g == null)
        {
            Toast.makeText(this, 0x7f0a00d7, 1).show();
            finish();
        }
        if(!(new File(g)).exists())
        {
            Toast.makeText(this, 0x7f0a00d7, 1).show();
            finish();
        }
        Uri uri = Uri.parse((new StringBuilder()).append("file://").append(g).toString());
        Intent intent = new Intent("android.intent.action.VIEW", uri);
        intent.setDataAndType(uri, "application/vnd.android.package-archive");
        intent.setClassName("com.android.packageinstaller", "com.android.packageinstaller.PackageInstallerActivity");
        startActivity(intent);
        finish();
    }

    private void i(int i1)
    {
        if(i != null)
            i.setMessage(getResources().getText(i1));
    }

    static boolean i(cls_PRISActivityUpdate prisactivityupdate)
    {
        return prisactivityupdate.j;
    }

    static Handler j(cls_PRISActivityUpdate prisactivityupdate)
    {
        return prisactivityupdate.A;
    }

    private void j(int i1)
    {
        z.setText(0x7f0a013e);
        setContentView(y, new android.widget.LinearLayout.LayoutParams(-1, -2));
    }

    private Dialog k(int i1)
    {
        android.app.AlertDialog.Builder builder = new android.app.AlertDialog.Builder(this);
        builder.setMessage(getResources().getText(i1)).setPositiveButton(getResources().getText(0x1040013), new cls_ey(this));
        return builder.create();
    }

    static ProgressDialog k(cls_PRISActivityUpdate prisactivityupdate)
    {
        return prisactivityupdate.i;
    }

    static Bundle l(cls_PRISActivityUpdate prisactivityupdate)
    {
        return prisactivityupdate.f;
    }

    private void l(int i1)
    {
        android.os.Message message = A.obtainMessage(2, i1, -1);
        A.sendMessage(message);
        if(b)
            com.nnee.p_g.cls_b.e(a, (new StringBuilder()).append("send message to handler to update download dialog, count == ").append(i1).toString());
    }

    static String m(cls_PRISActivityUpdate prisactivityupdate)
    {
        return prisactivityupdate.g;
    }

    static void n(cls_PRISActivityUpdate prisactivityupdate)
    {
        prisactivityupdate.y();
    }

    private void r()
    {
        String s1;
        File file;
        f = getIntent().getExtras();
        if(f == null || !f.containsKey("location") || !f.containsKey("size") || !f.containsKey("name") || !f.containsKey("md5") || !f.containsKey("version"))
        {
            Toast.makeText(this, 0x7f0a00d0, 1).show();
            finish();
        }
        s1 = f.getString("name");
        r = s1;
        if(b)
            com.nnee.p_g.cls_b.e(a, (new StringBuilder()).append("getData: pkgName == ").append(s1).toString());
        file = new File(cls_c.l);
        if(file != null) {
        	 String s2 = file.getPath();
             g = (new StringBuilder()).append(s2).append("/").append("download").append("/").append(s1).toString();
             if(b)
                 com.nnee.p_g.cls_b.e(a, (new StringBuilder()).append("packagePath==").append(g).toString());
             if(!g.matches(".*\\.apk"))
                 g = (new StringBuilder()).append(g).append(".apk").toString();
        } else {
        	showDialog(0x7f0a00ce);
        }
 
    }

    private void s()
    {
        if(f != null)
        {
            StringBuilder stringbuilder = new StringBuilder();
            stringbuilder.append("\n");
            stringbuilder.append(getText(0x7f0a00de));
            stringbuilder.append("\n\n");
            stringbuilder.append(getText(0x7f0a00df));
            stringbuilder.append("\n");
            stringbuilder.append(f.getString("version"));
            stringbuilder.append("\n\n");
            stringbuilder.append(getText(0x7f0a00e0));
            stringbuilder.append("  ");
            stringbuilder.append(com.nnee.p_pr.p_a.cls_i.b(Long.valueOf(f.getString("size")).longValue()));
            if(f.containsKey("function"))
            {
                ArrayList arraylist2 = f.getStringArrayList("function");
                if(arraylist2 != null && arraylist2.size() > 0)
                {
                    stringbuilder.append("\n\n");
                    stringbuilder.append(getText(0x7f0a00e1));
                    String s3;
                    for(Iterator iterator2 = arraylist2.iterator(); iterator2.hasNext(); stringbuilder.append(s3))
                    {
                        s3 = (String)iterator2.next();
                        stringbuilder.append("\n");
                    }

                }
            }
            if(f.containsKey("bugfix"))
            {
                ArrayList arraylist1 = f.getStringArrayList("bugfix");
                if(arraylist1 != null && arraylist1.size() > 0)
                {
                    stringbuilder.append("\n\n");
                    stringbuilder.append(getText(0x7f0a00e2));
                    String s2;
                    for(Iterator iterator1 = arraylist1.iterator(); iterator1.hasNext(); stringbuilder.append(s2))
                    {
                        s2 = (String)iterator1.next();
                        stringbuilder.append("\n");
                    }

                }
            }
            if(f.containsKey("others"))
            {
                ArrayList arraylist = f.getStringArrayList("others");
                if(arraylist != null && arraylist.size() > 0)
                {
                    stringbuilder.append("\n\n");
                    stringbuilder.append(getText(0x7f0a00e3));
                    String s1;
                    for(Iterator iterator = arraylist.iterator(); iterator.hasNext(); stringbuilder.append(s1))
                    {
                        s1 = (String)iterator.next();
                        stringbuilder.append("\n");
                    }

                }
            }
            ((TextView)findViewById(0x7f0d0138)).setText(stringbuilder.toString());
        }
    }

    private void t()
    {
        e = (Button)findViewById(0x7f0d013a);
        e.setOnClickListener(this);
        d = (Button)findViewById(0x7f0d0139);
        d.setOnClickListener(this);
        v = LayoutInflater.from(this).inflate(0x7f03004b, null, false);
        w = (TextView)v.findViewById(0x7f0d0115);
        x = (ProgressBar)v.findViewById(0x7f0d0116);
        y = LayoutInflater.from(this).inflate(0x7f03004a, null, false);
        z = (TextView)y.findViewById(0x7f0d0113);
    }

    private void u()
    {
        if(!j)
            if(!Environment.getExternalStorageState().equals("mounted"))
                showDialog(0x7f0a00ce);
            else
            if(!com.nnee.p_up.cls_c.a(this))
            {
                showDialog(0x7f0a00dc);
            } else
            {
                if(e != null)
                    e.setEnabled(false);
                j = true;
                w();
            }
    }

    private void v()
    {
        String s1;
        String s2;
        s1 = f.getString("location");
        s2 = f.getString("size");
        if(TextUtils.isEmpty(g)) {
        	throw new RuntimeException("packagePath is null or empty when calling onUpdate()!");
        }else {
        	File file = new File(g);
            if(file.length() < Long.valueOf(s2).longValue()) {
            	if(a(Long.valueOf(s2).longValue() - file.length()))
                   return;
                showDialog(0x7f0a00d2);
               
            } else {
            	long l1;
                file.delete();
                l1 = 0L;
                if(b)
                    com.nnee.p_g.cls_b.e(a, (new StringBuilder()).append("be about to update. Size of package to download is: ").append(s2).append(", old packet size is: ").append(l1).toString());
                a(s1, g, f.getString("md5"), l1, Long.valueOf(s2).longValue());
            }
        }
 
    }

    private void w()
    {
        if(b)
            com.nnee.p_g.cls_b.e(a, (new StringBuilder()).append("checkExist: packagePath == ").append(g).toString());
        A.post(new cls_ex(this));
    }

    private void x()
    {
        if(!TextUtils.isEmpty(g))
            (new File(g)).delete();
    }

    private void y()
    {
        String s1 = f.getString("version");
        if(!TextUtils.isEmpty(s1))
        {
            int i1 = s1.indexOf(" ");
            if(i1 > 0)
                s1 = s1.substring(0, i1);
        }
        com.nnee.p_up.cls_c.a(s1, null, this);
    }

    protected void a(int i1)
    {
        if(i1 > 0)
        {
            w.setText((new StringBuilder()).append(i1).append("%").toString());
            x.setProgress(i1);
        }
    }

    protected void b(int i1)
    {
        if(i1 > 0 && i != null)
        {
            i.setProgress(i1);
            if(b)
                com.nnee.p_g.cls_b.e(a, (new StringBuilder()).append("set download dialog progress, count == ").append(i1).toString());
        }
    }

    public void onClick(View view)
    {
       switch( view.getId()){
       case 2131558713:
    	   u();
    	   break;
       case 2131558714:
    	   finish();
    	   break;
       default:
    	   break;
       }
        
    }

    protected void onCreate(Bundle bundle)
    {
        super.onCreate(bundle);
        setContentView(0x7f030052);
        d(0x7f02008a);
        setTitle(0x7f0a013c);
        t();
        r();
        s();
        t = this;
        u = (NotificationManager)t.getSystemService("notification");
    }

    public Dialog onCreateDialog(int i1)
    {
    	 Object obj = null;
       switch( i1){
       case 1:
    	   i = new cls_fa(this, this);
           i.setProgressStyle(1);
           i.setMessage(getText(0x7f0a00e6));
           i.setButton(-2, getResources().getText(0x7f0a00cb), new cls_ez(this));
           obj = i;
    	   break;
       case 2131361998:
       case 2131362001:
       case 2131362002:
       case 2131362005:
       case 2131362006:
       case 2131362012:
       case 2131362013:
       case 2131362021:
       case 2131362023:
    	   obj = k(i1);
    	   break;
    	   default:
    		   break;
       }
        
        return ((Dialog) (obj));
 
    }

    public boolean onKeyDown(int i1, KeyEvent keyevent)
    {
        if(j && 4 == i1)
            f();
        return super.onKeyDown(i1, keyevent);
    }

    public void onPrepareDialog(int i1, Dialog dialog)
    {
       switch( i1){
       case 1:
    	   i = (ProgressDialog)dialog;
           i.setMessage(getText(0x7f0a00e6));
    	   break;
    	   default:
    		   super.onPrepareDialog(i1, dialog);
    		   break;
       }
      
    }

    private static String a = "UpdateConfirm";
    private static boolean b = false;
    private static boolean c = false;
    private static final int h = 0;
    private static final int l = -1;
    private static final int m = 1;
    private static final int n = 2;
    private static final int o = 3;
    private static final int p = 4;
    private static final int q = 5;
    private Handler A;
    private Button d;
    private Button e;
    private Bundle f;
    private String g;
    private ProgressDialog i;
    private boolean j;
    private Thread k;
    private String r;
    private cls_ProgressInfo s;
    private Context t;
    private NotificationManager u;
    private View v;
    private TextView w;
    private ProgressBar x;
    private View y;
    private TextView z;

    static 
    {
        b = false;
        c = false;
    }
}
